package com.example.accounting.controllers;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.accounting.entity.User;
import com.example.accounting.mappers.UserMapper;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class IndexController {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping({"", "/"})
    public ModelAndView index() {

        List<User> users = userMapper.selectList(new QueryWrapper<>());

        return new ModelAndView("index")
            .addObject("message", "Now is " + new Date())
            .addObject("users", users)
            ;
    }
}
